/*
 * Copyright (c) 2018.
 * http://www.ulabcare.com
 */

package com.mt.roll.upms.controller;

import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.core.base.BaseController;
import com.mt.roll.core.dto.LoginUser;
import com.mt.roll.core.dto.Permission;
import com.mt.roll.core.vo.LoginUserVo;
import com.mt.roll.core.vo.R;
import com.mt.roll.upms.service.UpmsService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.List;

/**
 * 平台通用权限管理控制器，提供给内部服务调用
 *
 * @author jiff
 * @date 2018/11/7
 * @since 1.0
 */
@RestController
@RequestMapping(CommonConstant.API_MODULE_UPMS +"upms")
@Slf4j
@Api(value = "平台权限管理", tags = "平台权限管理接口，提供给内部服务调用", hidden = true)
public class UpmsController extends BaseController {
    @Autowired
    private UpmsService upmsService;

    @PostMapping("login")
    private R<LoginUser> login(@RequestParam("mobile") String mobile, @RequestParam("password") String password) {
        return upmsService.login(mobile, password);
    }

    /**
     * 退出登录
     *
     * @return 处理结果
     */
    @PostMapping("logout")
    private R<Serializable> logout() {
        return upmsService.logout();
    }

    @PostMapping("getLoginUserByMobile")
    private R<LoginUser> getLoginUser(@RequestParam("mobile") String mobile) {
        return upmsService.getLoginUser(mobile);
    }

    @PostMapping(value = "getLoginUser")
    private R<LoginUserVo> getLoginUserVo() {
        return upmsService.getLoginUserVo();
    }

    @PostMapping("getPermissions")
    private List<Permission> getPermissions() {
        return upmsService.getPermissions();
    }

}
